/**
 * 
 */
package org.t2.backstage.module.gameserver.service;

import java.util.List;

import org.banish.sql.core.util.QuerySet;
import org.gaming.backstage.PageData;
import org.gaming.service.service.redis.OneToManyService;
import org.springframework.stereotype.Service;
import org.t2.backstage.module.gameserver.model.GameRegion;

/**
 * @author YY
 *
 */
@Service
public class GameRegionService extends OneToManyService<GameRegion> {


	public PageData<GameRegion> getList(int page, int pageSize) {
		QuerySet querySet = new QuerySet();
		querySet.limit(page, pageSize);
		querySet.orderBy("order by channel_id, region_id");
		querySet.formWhere();
		List<GameRegion> list = this.repository().getBaseDao().queryListWhere(querySet.getWhere(), querySet.getParams());
		
		PageData<GameRegion> pageData = new PageData<>();
		pageData.setCount(this.repository().getBaseDao().countWhere(querySet.getCountWhere(), querySet.getCountParams()));
		pageData.setData(list);
		return pageData;
	}

	@Override
	protected String namespace() {
		return "game_channel";
	}
	
	public GameRegion getById(long id) {
		QuerySet querySet = new QuerySet();
		querySet.addCondition("id = ?", id);
		querySet.formWhere();
		return this.repository().getBaseDao().queryOneWhere(querySet.getWhere(), querySet.getParams());
	}
}
